package com.tech.zhidengxian.controller;

import com.tech.zhidengxian.model.dto.CommentDTO;
import com.tech.zhidengxian.model.dto.result.ReturnResult;
import com.tech.zhidengxian.model.dto.result.ReturnResultUtils;
import com.tech.zhidengxian.service.api.CommentService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Resource
    private CommentService commentService;
    @RequestMapping("/queryCommentListByGoodsId")
    public ReturnResult<List<CommentDTO>> queryCommentListByGoodsId(Long goodsId){
        List<CommentDTO> commentDTOS = commentService.queryCommentListByGoodsId(goodsId);
        return ReturnResultUtils.returnSuccess(commentDTOS);
    }

    @RequestMapping("/publishComment")
    public ReturnResult<List<CommentDTO>> publishComment(@RequestBody CommentDTO commentDTO){
        CommentDTO commentDTOS = commentService.publishComment(commentDTO);
        //发送ws通知逻辑
        return ReturnResultUtils.returnSuccess(commentDTOS);
    }
}
